const CopyWebpackPlugin = require("copy-webpack-plugin");
const webpack = require("webpack");
const path = require('path')

let cesiumSource = './node_modules/cesium/Source'
let cesiumWorkers = '../Build/Cesium/Workers'
const resolve = dir => {
    return path.join(__dirname, dir)
  }
module.exports = {
    publicPath:'/dataView/', //base地址, 默认为/, 可修改.
    configureWebpack: {
        resolve: {
            alias: {
                '@': path.resolve('src'),
                'cesium': path.resolve(__dirname, cesiumSource)
            }
        },
        plugins: [
            // Copy Cesium Assets, Widgets, and Workers to a static directory
            new CopyWebpackPlugin( [
                    { from: "node_modules/cesium/Build/Cesium/Workers", to: "Workers" },
                    {
                        from: "node_modules/cesium/Build/Cesium/ThirdParty",
                        to: "ThirdParty"
                    },
                    { from: "node_modules/cesium/Build/Cesium/Assets", to: "Assets" },
                    { from: "node_modules/cesium/Build/Cesium/Widgets", to: "Widgets" }
                ]),
            new webpack.DefinePlugin({
                // Define relative base path in cesium for loading assets
                CESIUM_BASE_URL: JSON.stringify("")
            })
        ],
        module: {
            // Removes these errors: "Critical dependency: require function is used in a way in which dependencies cannot be statically extracted"
            // https://github.com/AnalyticalGraphicsInc/cesium-webpack-example/issues/6
            unknownContextCritical: false,
            unknownContextRegExp: /\/cesium\/cesium\/Source\/Core\/buildModuleUrl\.js/,

        },

    },

};
